package com.smartcommunity.service.people;

import com.alibaba.fastjson.JSONObject;
import com.smartcommunity.base.bean.PeopleFaceVid;
import com.smartcommunity.bean.entity.User;
import com.smartcommunity.bean.model.Pager;
import com.smartcommunity.bean.model.Result;
import com.smartcommunity.entity.people.*;
import com.smartcommunity.entity.people.dto.AddPeopleDto;
import com.smartcommunity.entity.people.dto.HouseDto;
import com.smartcommunity.entity.people.dto.UpdatePeopleDto;
import com.smartcommunity.entity.statistic.StatisticByTypeResp;

import java.util.List;
import java.util.Map;

/**
 * @Author: hujiangtao
 * @Date: 2018/1/13
 * @Description: 人员业务层接口
 * @Modified By:
 */
public interface PeopleService {

	/**
	 * 单表查询所有人员，不带权限
	 * @param queryMap
	 * @param currentPage
	 * @param pageSize
     * @return
     */
	Pager<People> getAllPeople(Map<String,Object> queryMap, int currentPage, int pageSize);
	/**
	 * 人员列表
	 * @param people
	 * @param currentPage
	 * @param pageSize
	 * @return
	 */
    Pager<People> listPeoples(People people, int currentPage, int pageSize, String sortField, String sortModel);
    /**
     * 人员数量
     * @param people
     * @return
     */
    int countPeoples(People people);
    /**
     * @Description: 根据条件查询
     * @param: paramMap
     * @return: List<People>
     * @author: minsheng
     * @date: 2019/1/15 10:42
     */
    List<People> listPeoplesByParam(Map<String, String> paramMap);
	/**
	 * 实有人口分类统计
	 * @return
	 */
    Map<String,Object> countPeopleByType(Map<String, Object> paramMap);
	Map<String,Object> countPeopleByTypeEs(Map<String, Object> paramMap);

	Map<String,Object> countResidentiaTypeEs(Map<String, Object> paramMap);

	/**
	 * 查询基本信息
	 * @param map
	 * @return
     */
	People getPeopleBaseInfo(Map<String, String> map, List<String> villageCodes);


	/**
	 * 添加人员信息
	 * @param addPeopleDto 请求参数
	 */
	Result insertPeople (AddPeopleDto addPeopleDto);

	/**
	 * 删除实有人员
	 * @param credentialNos 证件号credentialNo，多个证件号用“,”号进行分割，例如：321124521,2233115,1112235
	 */
	Result deletePeople(String credentialNos);

	/**
	 * 更新人员信息
	 * @param updatePeopleDto 请求参数
	 */
	Result updatePeople(UpdatePeopleDto updatePeopleDto);

	/**
	 * 更新人员信息
	 * @param people 请求参数
	 */
	void updatePeoplePic(People people);

    /**
     * @Description: 按小区统计实有人口
     * @param: Map<String, Object>
     * @return: List<Map<String, Object>>
     * @author: minsheng
     * @date: 2019/1/4 13:11
     */
    List<Map<String, Object>> listRealPeopleGroup(Map<String, Object> recordMap);

    /**
     * @Description: 根据条件查询人员信息
     * @param: Map<String, String>
     * @return: List<People>
     * @author: minsheng
     * @date: 2019/1/15 10:20
     */
    List<People> listAllPeoples(Map<String, String> paramMap);

    /**
     * 人员数量
     * @param people
     * @return
     */
    int queryPeopleListCount(People people);


    /**
     * @Description: 根据orgId统计人口数量
     * @param: id
     * @return: int
     * @auther: minsheng
     * @date: 2019/3/1 13:52
     */
	int countPeopleByOrgId(Map<String, Object> param);

	/**
	 * 查询小区内所有的前科人员
	 * @param param
	 * @return
	 */
    List<People> listExCriminalByVillage(Map<String, Object> param);


	/**
	 * 一人一档-抓拍地点top10
	 * @param vid
	 * @param topN
	 * @return
	 */
	List<JSONObject> vidShowCameraCount(String vid, int topN);


	/**
	 * 抓拍规律（近7天）
	 * @param vid
	 * @return
	 */
	List<JSONObject> vidLast7DayCount(Long vid);


	/**
	 * 查询人脸VID信息
	 * @param
	 * @return
	 */
	PeopleFaceVid getPeopleFaceVid(Long vid);


    People queryPeopleBaseInfo(String credentialNo);

    /**
     * 根据标签统计
     * @param param
     * @return
     */
    Map<String, Object> countByTag(Map<String, Object> param);

    StringBuilder getLeafOrgIds(Integer parentId, StringBuilder sb);

	/**
	 * 统计实有人员相关数据
	 * @param params
	 * @return
	 */
	int countRealPeoples(Map<String, Object> params);

	List<VidPeopleSense> queryPeopleCount(Map<String, Object> params);

    /**
     * 查询同住人员基本信息
     */
    List<People> queryLiveTogetherPeople(String credentialNo);

	List<People> listPeoplesByVids (String str);

	List<People> listPeoplesByCardIds (String str);

	/**
	 * 同步人员vid信息
	 */
	void syncPeopleVid();

    Integer countByTagGroup(String villageCode, String groupId);

    /**
     * 实有人口迁入
     */
    Result moveIn(RealPeopleHouseMove realPeopleHouseMove, User user);

    /**
     * 实有人口迁出
     */
    Result moveOut(RealPeopleHouseMove realPeopleHouseMove, User user);

    /**
     * 实有人口迁入迁出记录
     */
    List<RealPeopleHouseMove> moveList(String credentialNo);

	Result bindVid(PeopleSearchModel peopleSearch);

	Result unbindVid(PeopleSearchModel peopleSearch);
    List<People> getPeopleByName(String name);

	List<People> getPeopleByCredentialNo(List<String> credentialNos);


	/**
	 * 从引擎同步Vid和特征id（添加和修改人员时使用）
	 * @param idcardList 身份证列表
	 */
	void updateVidAndFeatureIdByEngine(List<String> idcardList);

    Integer getAllPeopleCount();

	List<StatisticByTypeResp> getPeopleTypeCount();
	
	/**
	 * 实有人口-数据迁移到ES-basedata索引
	 */
	Result syncDataToEs(String villageCode, String buildingNo) throws Exception;
	
	/**
	 * 人员列表
	 * @param people
	 * @param currentPage
	 * @param pageSize
	 * @return
	 */
    Pager<People> listPeoplesForFullSearch(People people, int currentPage, int pageSize);
    
    /**
     * 新增人房关系
     */
	Result insertPeopleHouse(List<HouseDto> list);
}
